/*! \file mem_c_profile.h
 *	\brief <write description for mem_c_profile.h>
 *
 *	created:	2009/11/20
 *	created:	20:11:2009   18:18
 *	filename: 	o:\main\libs\mem\mem_c_profile.h
 *	file path:	o:\main\libs\mem
 *	file base:	mem_c_profile
 *	file ext:	h
 *	author:		Vitalii Trubchaninov
 *				venngraydog@gmail.com
 */

#ifndef _MEM_MEM_C_PROFILE_H_
#define _MEM_MEM_C_PROFILE_H_

#pragma once

#include "defs.h"

#if TT_MEM_ENABLED && TT_MEM_PROFILING

#	ifdef __cplusplus
extern "C"{
#	endif 

MEM_API void* mem_c_root_section(const char* root_section_name);
MEM_API void mem_c_register_new(void* section, unsigned int size);
MEM_API void mem_c_register_delete(void* section, unsigned int size);

MEM_API void* mem_c_new(void* section, unsigned int size);
MEM_API unsigned int mem_c_size(void* p);
MEM_API void mem_c_delete(void* p);

#	ifdef __cplusplus
}; //extern C
#	endif

#define MEM_C_ROOT_SECTION(root_section_name) mem_c_root_section(root_section_name)
#define MEM_C_REGISTER_NEW(section, size) mem_c_register_new(section, size)
#define MEM_C_REGISTER_DELETE(section, size) mem_c_register_delete(section, size)

#define MEM_C_NEW(section, size) mem_c_new(section, size)
#define MEM_C_SIZE(p) mem_c_size(p)
#define MEM_C_DELETE(p) mem_c_delete(p)

#else //TT_MEM_ENABLED && TT_MEM_PROFILING

#define MEM_C_ROOT_SECTION(root_section_name) (0)
#define MEM_C_REGISTER_NEW(section, size) ((void)0)
#define MEM_C_REGISTER_DELETE(section, size) ((void)0)

#define MEM_C_NEW(section, size) malloc(size)
#define MEM_C_SIZE(p) _msize(p)
#define MEM_C_DELETE(p) free(p)

#endif //TT_MEM_ENABLED && TT_MEM_PROFILING

#endif //_MEM_MEM_C_PROFILE_H_
